local skel = fk.CreateSkill {
  name = "emo__shengyu",
  tags = { Skill.Charge },
}

Fk:loadTranslationTable{
  ["emo__shengyu"] = "圣域",
  [":emo__shengyu"] = "蓄力技（1/4），①每当你造成伤害后，你获得等于伤害值的蓄力值，然后获得/失去“硬币”；②结束阶段，你可以消耗4点蓄力值，摸牌至体力上限并执行一个额外的出牌阶段。",

  ["#emo__shengyu-invoke"] = "圣域：你可以摸牌至体力上限，执行一个额外的出牌阶段",
  ["@@emo__coin"] = "<font color='#ff9900'>硬币</font>",

  ["$emo__shengyu1"] = "喜欢疼痛的感觉吗",
  ["$emo__shengyu2"] = "乱数圣域",
  ["$emo__shengyu3"] = "盛宴开始",
}

local U = require "packages.utility.utility"


skel:addEffect(fk.Damage, {
  anim_type = "drawcard",
  audio_index = {1, 3},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(skel.name)
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    U.skillCharged(player, data.damage)
    room:setPlayerMark(player, "@@emo__coin", (player:getMark("@@emo__coin") + 1) % 2)
  end,
})

skel:addEffect(fk.EventPhaseEnd, {
  anim_type = "drawcard",
  audio_index = 2,
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(skel.name) and player.phase == Player.Finish then
      return player:getMark("skill_charge") >= 4
    end
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askToSkillInvoke(player, { skill_name = skel.name, prompt = "#emo__shengyu-invoke"})
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    U.skillCharged(player, -4)
    local x = player.maxHp - player:getHandcardNum()
    if x > 0 then
      player:drawCards(x, skel.name)
    end
    if not player.dead then
      player:gainAnExtraPhase(Player.Play, skel.name, true)
    end
  end,
})

skel:addAcquireEffect(function (self, player)
  U.skillCharged(player, 1, 4)
end)

skel:addLoseEffect(function (self, player)
  U.skillCharged(player, -1, -4)
end)

return skel
